package com.hjt.gulimall.member.web;

import com.alibaba.fastjson.JSON;
import com.hjt.common.utils.Constant;
import com.hjt.common.utils.R;
import com.hjt.gulimall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * @author:97007
 * @date:2021/10/16 10:06
 */
@Controller
public class MemberWebController {

    @Autowired
    private OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, Model model) {

        // 查出用户的所有订单列表数据
        Map<String, Object> params = new HashMap<>();
        params.put(Constant.PAGE, pageNum.toString());
        R r = orderFeignService.pageWithItem(params);
        System.out.println(JSON.toJSONString(r));
        model.addAttribute("orders", r);
        return "orderList";
    }
}
